import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);


import Classify from "./Classify"
import { ycb } from "./ycb";
import yptrouter from "./yptrouter";
import zhyrouter from './zhyrouter';



//创建vue-router对象


let routes = [...Classify, ...zhyrouter,...yptrouter,...ycb]



let router = new VueRouter({
    routes
})


//全局前置守卫
router.beforeEach((to, from, next) => {

    console.log(to.matched[0].path)
        // console.log(from);
        // console.log("前置守卫");
        // next()



    if (to.path == "/Classify01S01") {
        if (localStorage.getItem('username')) {
            next();
        } else {
            next("/login");
        }
    } else if (to.matched[0].path == "/Classify01S") {
        if (localStorage.getItem('username')) {
            next();
        } else {
            next("/login");
        }
    } else {
        next()
    }




});


export default router